﻿Public Class frmThanhToan


    Public Event OnThanhToan As EventHandler(Of EventArgs)
    Protected Sub SetTShanhToan(ban As Ban)
        RaiseEvent OnThanhToan(ban, New EventArgs())
    End Sub
    Public Ban As Ban
    Public DonHang As DonHang



    Private Sub frmThanhToan_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        lblBan.Text = Ban.Ten
        lblTongTien.Text = String.Format("Thành tiền: {0} VNĐ", DonHang.ThanhTien.Format())
    End Sub

    Private Sub btnDongVaIn_Click(sender As System.Object, e As System.EventArgs) Handles btnDongVaIn.Click
        ThanhToan()
    End Sub

    Private Sub btnDongVaKhongIn_Click(sender As System.Object, e As System.EventArgs) Handles btnDongVaKhongIn.Click
        ThanhToan()
    End Sub
    Sub ThanhToan()
        Using Db = New QlqaContext
            Dim dh As DonHang = Db.DonHangs.FirstOrDefault(Function(x) x.Id = DonHang.Id)
            Dim b As Ban = Db.Bans.FirstOrDefault(Function(x) x.Id = Ban.Id)
            dh.DaThanhToan = True
            b.DaSuDung = False
            b.IdDonHang = 0
            Db.SaveChanges()
            SetTShanhToan(b)
        End Using


    End Sub
    Private Sub btnXemThubill_Click(sender As System.Object, e As System.EventArgs) Handles btnXemThubill.Click
        LamSau()
    End Sub

    Sub LamSau()
        MessageBox.Show("Làm sau", "Thông báo")
    End Sub

End Class